package com.tyut.service.impl;

import com.tyut.mapper.ManagerMapper;
import com.tyut.pojo.Manager;
import com.tyut.service.ManagerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 管理员业务层
 */
@Service
@Transactional
public class ManagerServiceImpl implements ManagerService {
    @Resource
    private ManagerMapper managerMapper;
    /**
     * 添加管理员
     * @param manager
     */
    public boolean addManager(Manager manager) {
        return managerMapper.addManager(manager) > 0;
    }

    /**
     * 删除管理员
     * @param manid
     */
    public boolean deleteManager(Integer manid) {
        return managerMapper.deleteManager(manid) > 0;
    }

    /**
     * 修改管理员信息
     * @param manager
     */
    public boolean updateManager(Manager manager) {
        return managerMapper.updateManager(manager) > 0;
    }

    /**
     * 查询所有的管理员
     * @return
     */
    public List<Manager> queryListManager() {
        List<Manager> managers = managerMapper.queryListManager();
        return managers;
    }

    /**
     * 根据id查询管理员
     * @param manid
     * @return
     */
    public Manager queryManagerById(Integer manid) {
        Manager manager = managerMapper.queryManagerById(manid);
        return manager;
    }

    @Override
    public Manager loginManager(Manager manager) {
        Manager manager1 = managerMapper.loginManager(manager);
        return manager1;
    }
}
